
/**
 * Copyright (c) subnew
 * Licensed under the GPL;
 * @email:joseanluo@gmail.com
 * @Title: SysMenu.java
 * @Package com.subnew.copyman.modules.sys.entity
 */
package com.subnew.mango.modules.sys.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.subnew.mango.frame.dao.entity.BaseEntity;


/**
 * 系统菜单功能实体
 *@author JoseanLuo  
 * @date  2014年9月17日 下午2:35:33
 * @version V1.0<br>
 *          V2.0 关联关系加入 20141223 
 */
@Entity
@Table(name = "sys_menu")
public class SysMenu extends  BaseEntity {
	
	/**
	 * 菜单名
	 */
	private String name;
	/**
	 * 菜单链接
	 */
	private String linkurl;
	/**
	 * 菜单图标
	 */
	private String iconcls;
	/**
	 * 菜单类型
	 */
	private Integer mtype;
	/**
	 * 菜单描述
	 */
	private String memo;
	
	
	/**
	 * 父菜单
	 */
	private SysMenu sysMenu;
	/**
	 * 子菜单
	 */
	private Set<SysMenu> sysMenus = new HashSet<SysMenu>(0);
	/**
	 * 菜单可被访问的角色
	 */
	private Set<SysRole> sysRoles = new HashSet<SysRole>(0);
	

	@Column(name = "name")
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "linkurl", length = 200)
	public String getLinkurl() {
		return this.linkurl;
	}

	public void setLinkurl(String linkurl) {
		this.linkurl = linkurl;
	}

	@Column(name = "iconcls", length = 100)
	public String getIconcls() {
		return this.iconcls;
	}

	public void setIconcls(String iconcls) {
		this.iconcls = iconcls;
	}

	@Column(name = "mtype")
	public Integer getMtype() {
		return this.mtype;
	}

	public void setMtype(Integer mtype) {
		this.mtype = mtype;
	}

	@Column(name = "memo")
	public String getMemo() {
		return this.memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pid", nullable = false)
	public SysMenu getSysMenu() {
		return this.sysMenu;
	}

	public void setSysMenu(SysMenu sysMenu) {
		this.sysMenu = sysMenu;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "sysMenu")
	public Set<SysMenu> getSysMenus() {
		return this.sysMenus;
	}

	public void setSysMenus(Set<SysMenu> sysMenus) {
		this.sysMenus = sysMenus;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "sysMenus")
	public Set<SysRole> getSysRoles() {
		return this.sysRoles;
	}

	public void setSysRoles(Set<SysRole> sysRoles) {
		this.sysRoles = sysRoles;
	}
}
